<template>
    <h1>路由传参（发起）</h1>
    <h2>当前路由：{{ route.path }}</h2>
    <h2>当前路由全路径：{{ route.fullPath }}</h2>

    <button @click="toB">点击跳转并传参</button>
    <p style="text-align: left;border-top: 1px solid #000;">
        使用 useRouter()中的push()方法，在 query 属性中添加需要传递的参数
    </p>
</template>

<script lang="ts">
import { useRouter, useRoute } from 'vue-router'
export default {
    name: 'router_routeA',
    setup() {

        const router = useRouter()
        
        const route = useRoute()
        console.log(route);
        

        function toB() {
            router.push({
                path:'/router_routeB',
                query: {
                    name:'张三',
                    age:22
                }
            })

        }

        return {
            toB,
            route
        }
    }
} 
</script>
<style></style>